package com.matt.service.impl;

import com.matt.foundation.utils.DateUtil;
import com.matt.service.SchedulerPlanService;
import com.matt.service.SchedulerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/7/25
 * *******************************
 */
@Service
@Slf4j
@Transactional
public class SchedulerServiceImpl implements SchedulerService {

    @Autowired
    private SchedulerPlanService schedulerPlanService;

    @Override
    public Boolean dailyClearTask(String time) {
        Date todayBegin = DateUtil.parseToDateMilis(time);

        log.info("生成待续约可贺 定时任务 开始处理  ==================");
        schedulerPlanService.generateRenewalClientele(todayBegin);

        log.info("合同开始状态 定时任务 开始处理  ==================");
        schedulerPlanService.beginContract(todayBegin);

        log.info("合同结束状态 定时任务 开始处理  ==================");
        schedulerPlanService.endContract(todayBegin);

        log.info("历史客单价 定时任务 开始处理  ==================");
        schedulerPlanService.generateStatPaidContract(todayBegin);

        log.info("每日定时任务 处理完成  ================");

        return true;
    }
}
